//
//  MultiLanguageTextField.m
//  pa
//
//  Created by HaiJiao Chen on 12-7-21.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "MultiLanguageTextField.h"
#import "FilePack.h"

@implementation MultiLanguageTextField
@synthesize placeHolderId;

-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        placeHolderId = -1;
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageChange:) name:MultiLanguageChangeNotification object:nil];
    }
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self)
    {
        placeHolderId = [self.placeholder intValue];;
        self.placeholder = [FilePack getStringByID:placeHolderId];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageChange:) name:MultiLanguageChangeNotification object:nil];
    }
    return self;
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

- (void)setPlaceHolderId:(int)_placeHolderId
{
    if (placeHolderId != _placeHolderId)
    {
        placeHolderId = _placeHolderId;
        self.placeholder = [FilePack getStringByID:placeHolderId];
    }
}

- (void)languageChange:(NSNotification* )note
{
    //NSString* lan = [note object];
    self.placeholder = [FilePack getStringByID:placeHolderId];
}

@end
